let container, msg;

window.onload = function () {
    container = document.getElementById("box");
    msg = document.getElementById("msg");

    container.ondragover = function (ev) {
        ev.preventDefault();

    }
    container.ondrop = function (ev) {
        ev.preventDefault();
        let file = ev.dataTransfer.files[0]
        let reader = new FileReader();
        reader.onload = function (e) {
            container.innerHTML = "<img src=\"" + reader.result + "\" alt=\"图片\">";

            msg.innerHTML = reader.result;
        }
        reader.readAsDataURL(file);
    }

}

function showMessage(ev) {
    let msg = "";
    for (k in ev) {
        msg += k + ":" + ev[k] + "<br/>";
    }
    return msg;
}
